<?php
/**
 * Page Template
 *
 * Loaded automatically by index.php?main_page=shopping_cart.<br />
 * Displays shopping-cart contents
 *
 * @package templateSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_shopping_cart_default.php 5554 2007-01-07 02:45:29Z drbyte $
 */
?>
<div id="shoppingCartDefault">
<?php
  if ($flagHasCartContents) {
?>

<?php if ($messageStack->size('shopping_cart') > 0) echo $messageStack->output('shopping_cart'); ?>

<?php echo zen_draw_form('cart_quantity', zen_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>


<?php  if ($flagAnyOutOfStock) { ?>

<?php    if (STOCK_ALLOW_CHECKOUT == 'true') {  ?>

<div class="messageStackError"><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></div>

<?php    } else { ?>
<div class="messageStackError"><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></div>

<?php    } //endif STOCK_ALLOW_CHECKOUT ?>
<?php  } //endif flagAnyOutOfStock ?>

<div class="TableWrap">
  <ul class="tab">   
    <li><?php echo HEADING_TITLE; ?></li>
  </ul> <br class="clearBoth" />
  <table width="100%" cellpadding="0" cellspacing="0"  class="list" summary="ShoppingCartInfo">
    <thead>
      <tr>
        <th width="12%"><?php echo TABLE_HEADING_IMAGE; ?></th>
        <th width="32%"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
        <th width="12%"><?php echo TABLE_HEADING_PRICE; ?></th>
        <th width="20%"><?php echo TABLE_HEADING_QUANTITY_WEIGHT; ?></th>
		<th width="10%"><?php echo SUB_TITLE_SUB_TOTAL; ?></th>
        <th width="5%"></th>
      </tr>
    </thead>
    <tbody> <!-- Loop through all products /-->
        <?php
  foreach ($productArray as $product) {
?>
     <tr >
       <td >
       <a href="<?php echo $product['linkProductsName']; ?>"><?php echo $product['productsImage']; ?></a>
       </td>
       <td>
       <a href="<?php echo $product['linkProductsName']; ?>"><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a>
       </td>
       <td ><?php echo $product['perPrice']; ?></td>
	   <td>       
       <?php
		  if ($product['flagShowFixedQuantity']) {
			  echo $product['attributeHiddenField'];
			  if (isset($product['attributes']) && is_array($product['attributes'])) {
			    reset($product['attributes']);
			    foreach ($product['attributes'] as $option => $value) {
			   		//echo nl2br($value['products_options_values_name']);
					   echo $product['productsPrice']/$product['perPrice']*1000;
					   echo TEXT_PRODUCT_WEIGHT_UNIT; 
				}
			}		    
		  } else {
		     echo $product['showFixedQuantityAmount'];
		  }
		?>
	</td>

       <td ><?php echo $product['productsPrice']; ?></td>
       
       <td >
<?php
  if ($product['buttonDelete']) {
?>
           <a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&product_id=' . $product['id']); ?>"><?php echo zen_image($template->get_template_dir(ICON_IMAGE_TRASH, DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/' . ICON_IMAGE_TRASH, ICON_TRASH_ALT); ?></a>
<?php
  }
?>
</td>
     </tr>
<?php
  } // end foreach ($productArray as $product)
?>
  <!-- Finished loop through all products /-->
    </tbody>
  </table>
  <div id="cartSubTotal"><?php echo SUB_TITLE_TOTAL; ?> <?php echo $cartShowTotal; ?></div>
</div>

<br class="clearBoth" />

<!--bof shopping cart buttons-->
<div id="continueShop"><?php echo '<a href="' . zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . zen_image_button(BUTTON_IMAGE_CHECKOUT, BUTTON_CHECKOUT_ALT) . '</a>'; ?><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT) . '</a>'; ?></div>

<!--eof shopping cart buttons-->
</form>

<br class="clearBoth" />


<!-- ** BEGIN PAYPAL EXPRESS CHECKOUT ** -->
<?php  // the tpl_ec_button template only displays EC option if cart contents >0 and value >0
if (defined('MODULE_PAYMENT_PAYPALWPP_STATUS') && MODULE_PAYMENT_PAYPALWPP_STATUS == 'True') {
  include(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/paypal/tpl_ec_button.php');
}
?>
<!-- ** END PAYPAL EXPRESS CHECKOUT ** -->


<?php
  } else {
?>

<h2 id="cartEmptyText"><?php echo TEXT_CART_EMPTY; ?></h2>

<?php
$show_display_shopping_cart_empty = $db->Execute(SQL_SHOW_SHOPPING_CART_EMPTY);

while (!$show_display_shopping_cart_empty->EOF) {
?>

<?php
  if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_FEATURED_PRODUCTS') { ?>
<?php
/**
 * display the Featured Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>

<?php
  if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_SPECIALS_PRODUCTS') { ?>
<?php
/**
 * display the Special Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_specials_default.php'); ?>
<?php } ?>

<?php
  if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_NEW_PRODUCTS') { ?>
<?php
/**
 * display the New Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?>
<?php } ?>

<?php
  if ($show_display_shopping_cart_empty->fields['configuration_key'] == 'SHOW_SHOPPING_CART_EMPTY_UPCOMING') {
    include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS));
  }
?>
<?php
  $show_display_shopping_cart_empty->MoveNext();
} // !EOF
?>
<?php
  }
?>
</div>
